<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
<style type="text/css">
#main {
    text-align: center;
    width: 60%;
    margin: 0 auto;
}
.title {
    font-size: 22px;
    color: #3498DB;
    margin-bottom: 8px;
}
.info-author {
    font-size: 16px;
    color: #3498DB;
    margin-bottom: 20px;
}
.info-time {
    margin-left: 30px;
    color: #999999;
}
.desc {
    margin-top: 35px;
    text-align: left;
}
.title-desc {
    font-size: 18px;
    color: #3498DB;
    font-weight: bold;
    margin-bottom: 10px;
}
.source-packet {
    font-size: 16px;
}
</style>
<div class="page-header">
	<h1>资源详情</h1>
</div>
<div id="main">
    <div class="title"><?= $source['title'] ?></div>
    <div class="info-author">
        <span class="author">
            <i class="fa fa-user"></i>【<?= $source['school_name'] ?>】<?= $source['username'] ?>
        </span>
        <span class="info-time">
            <i class="fa fa-cloud-upload"></i>
            上传于
            <span class="createtime"><?= $source['createtime'] ?></span>
        </span>
    </div>
    <?php if($source['format'] !== SOURCE_FORMAT_IMAGE_TEXT): ?>
        <div class="content">
            <?php if($source['format'] === SOURCE_FORMAT_VIDEO): ?>
                <video controls="controls" src="<?= json_decode($source['link'], true)['link'] ?>" style="max-height: 600px;"></video>
            <?php elseif($source['format'] === SOURCE_FORMAT_AUDIO): ?>
                <audio id="audio" src="<?= json_decode($source['link'], true)['link'] ?>" controls="controls"></audio>
            <?php elseif($source['format'] === SOURCE_FORMAT_OTHER): ?>
                <?php if(strstr($source['link'], '.pdf')): ?>
                    <div id="handout_wrap_inner"></div>
                <?php elseif(strstr($source['link'], '.zip') || strstr($source['link'], '.rar') || strstr($source['link'], '.gz') || strstr($source['link'], '.z')): ?>
                    <a href="<?= json_decode($source['link'], true)['link'] ?>">
                        <div class="source-packet green">
                            点击下载压缩包：&nbsp;&nbsp;&nbsp;&nbsp;
                            <i class="ace-icon fa fa-download bigger-110"></i>
                            <?= json_decode($source['link'], true)['name'] ?>
                        </div>
                    </a>
                <?php else: ?>
                    <div style="height:35vw">
                        <iframe
                            src='https://view.officeapps.live.com/op/view.aspx?src=<?= json_decode($source['link'], true)['link'] ?>'
                            width='100%' height='100%' frameborder='1'>
                        </iframe>
                    </div>
                <?php endif ?>        
            <?php endif ?>
        </div>
    <?php endif ?>
    <div class="desc">
        <?php if($source['format'] !== SOURCE_FORMAT_IMAGE_TEXT && !empty(trim($source['desc']))): ?>
            <div class="title-desc">内容简介</div>
        <?php endif ?>
        <?= $source['desc'] ?>
    </div>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
    $(function(){
        <?php if($source['format'] === SOURCE_FORMAT_OTHER): ?>
            $('#handout_wrap_inner').media({
                width: '100%',
                height: '600px',
                autoplay: true,
                src:'<?= json_decode($source['link'], true)['link'] ?>'
            });
        <?php endif ?>
    })
</script>